//
//  FirstPageHeadView.m
//  CoachsBook
//
//  Created by MaBookPro on 2022/8/8.
//

#import "FirstPageHeadView.h"

@implementation FirstPageHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self CreateUI];
    }
    return self;
}
-(void)CreateUI{

    
    _PleaseLoginBtn = [[UIButton alloc]initWithFrame:CGRectMake(15, 20, APPwidth-30, 75)];
    [_PleaseLoginBtn setBackgroundImage:[UIImage imageNamed:@"blueback"] forState:0];
    _PleaseLoginBtn.layer.shadowOffset = CGSizeMake(1, 1);
    _PleaseLoginBtn.layer.shadowColor = [UIColor grayColor].CGColor;
    _PleaseLoginBtn.layer.shadowOpacity = 0.8;
    [self addSubview:_PleaseLoginBtn];
    
    
    UIImageView *circleimgv = [[UIImageView alloc]initWithFrame:CGRectMake(15, 15, 40, 40)];
    circleimgv.image = [UIImage imageNamed:@"headicon"];
    circleimgv.layer.cornerRadius = 40/2;
    circleimgv.userInteractionEnabled = YES;
    [_PleaseLoginBtn addSubview:circleimgv];
    
    
    UILabel *PleaseLoginLab = [[UILabel alloc]initWithFrame:CGRectMake(circleimgv.frame.size.width+circleimgv.frame.origin.x+10, 15, 80, 15)];
    PleaseLoginLab.text = @"请登录~";
    PleaseLoginLab.textColor = [UIColor blackColor];
    PleaseLoginLab.textAlignment = 0;
    PleaseLoginLab.font = [UIFont systemFontOfSize:14];
    [_PleaseLoginBtn addSubview:PleaseLoginLab];
    
    UILabel *welcomeDoingLab = [[UILabel alloc]initWithFrame:CGRectMake(circleimgv.frame.size.width+circleimgv.frame.origin.x+10, PleaseLoginLab.frame.size.height+PleaseLoginLab.frame.origin.y+10, 120, 15)];
    welcomeDoingLab.text = @"欢迎您使用教练宝典";
    welcomeDoingLab.textColor = [UIColor grayColor];
    welcomeDoingLab.textAlignment = 0;
    welcomeDoingLab.font = [UIFont systemFontOfSize:12];
    [_PleaseLoginBtn addSubview:welcomeDoingLab];
    
    //我的数据背景
    UIView *myStudentBackView = [[UIView alloc]initWithFrame:CGRectMake(0, _PleaseLoginBtn.frame.size.height+_PleaseLoginBtn.frame.origin.y, APPwidth, 270)];
    myStudentBackView.backgroundColor = [UIColor whiteColor];
    [self addSubview:myStudentBackView];
    
    NSArray *myStudents = @[@"我的学员",@"我的约课",@"语音播报",@"招生线索"];
    NSArray *mystudentImgs = @[@"studenticon",@"studenticon-1",@"studenticon-2",@"studenticon-3"];
    for (int i = 0; i < myStudents.count; i++) {
        
        UIButton *myBtn = [[UIButton alloc]initWithFrame:CGRectMake(i*APPwidth/4, 10, APPwidth/4, 60)];
        [myBtn setTitle:myStudents[i] forState:0];
        [myBtn setImage:[UIImage imageNamed:mystudentImgs[i]] forState:0];
        myBtn.titleLabel.textAlignment = 1;
        myBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [myBtn setTitleColor:[UIColor blackColor] forState:0];
        myBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 25, 10, 25);
        [myBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
        myBtn.titleEdgeInsets = UIEdgeInsetsMake(60, -50, 0, 0);
        [myStudentBackView addSubview:myBtn];
        
        if (i == 0) {
            _mystudentBtn = myBtn;
        }else if(i == 1){
            _myClassBtn = myBtn;
        }else if (i == 2){
            _voicePlayBtn = myBtn;
        }else{
            _admissionsLeadsBtn = myBtn;
        }
        
    }
    
    //线
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, _PleaseLoginBtn.frame.size.height+_PleaseLoginBtn.frame.origin.y, APPwidth, 10)];
    line.backgroundColor = rgba(245, 245, 250, 1);
    [myStudentBackView addSubview:line];

    //我的数据
    UIView *myDataLineV = [[UIView alloc]initWithFrame:CGRectMake(15, line.frame.size.height+line.frame.origin.y+15, 3, 15)];
    myDataLineV.backgroundColor = rgba(22, 120, 255, 1);
    myDataLineV.layer.cornerRadius = 2;
    [myStudentBackView addSubview:myDataLineV];
    UILabel *myDataLab = [[UILabel alloc]initWithFrame:CGRectMake(myDataLineV.frame.size.width+myDataLineV.frame.origin.x+5, line.frame.size.height+line.frame.origin.y+15, 70, 15)];
    myDataLab.text = @"我的数据";
    myDataLab.textColor = [UIColor blackColor];
    myDataLab.textAlignment = 0;
    myDataLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [myStudentBackView addSubview:myDataLab];

    
    UIImageView *dataGreenImgV = [[UIImageView alloc]initWithFrame:CGRectMake(15, myDataLab.frame.size.height+myDataLab.frame.origin.y+ 15, APPwidth-30, 85)];
    dataGreenImgV.image = [UIImage imageNamed:@"blueback-1"];
    dataGreenImgV.userInteractionEnabled = YES;
    [myStudentBackView addSubview:dataGreenImgV];
    
    NSArray *dataarr = @[@"12",@"8",@"16",@"6"];
    NSArray *dataLabarr = @[@"我的学员",@"今日约课",@"今日约考",@"本月约考"];

    for (int j = 0; j < dataarr.count; j++) {
        UIButton *dateBtn = [[UIButton alloc]initWithFrame:CGRectMake(dataGreenImgV.frame.size.width/4*j, 0, dataGreenImgV.frame.size.width/4, 60)];
        [dateBtn setTitle:dataarr[j] forState:0];
        [dateBtn setTitleColor:rgba(22, 120, 255, 1) forState:0];
        dateBtn.contentHorizontalAlignment = 0;
        dateBtn.titleLabel.font = [UIFont systemFontOfSize:20 weight:bold];
        [dataGreenImgV addSubview:dateBtn];

        
        UILabel *mydatetitle = [[UILabel alloc]initWithFrame:CGRectMake(0, 50, dataGreenImgV.frame.size.width/4, 20)];
        mydatetitle.text = dataLabarr[j];
        mydatetitle.textColor = rgba(51, 51, 51, 1);
        mydatetitle.textAlignment = 1;
        mydatetitle.font = [UIFont systemFontOfSize:14];
        [dateBtn addSubview:mydatetitle];
        
        if (j == 0 ) {
            
        }else if (j == 1){
            _todayClassBtn = dateBtn;
        }
        
        
        
    }

    
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, dataGreenImgV.frame.size.height+dataGreenImgV.frame.origin.y+15, APPwidth, 10)];
    line1.backgroundColor = rgba(245, 245, 250, 1);
    [myStudentBackView addSubview:line1];

//    

    
}


@end
